/**
 * 
 */
package com.pmsco.pms.services.impl;

import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.pmsco.pms.core.dao.PmsUserDao;
import com.pmsco.pms.core.domain.PmsUser;
import com.pmsco.pms.services.interfaces.PmsUserService;

/**
 * @author Long Tran
 *
 */
public class PmsUserServiceImpl implements PmsUserService {
	private static final Logger logger = LoggerFactory.getLogger(PmsUserServiceImpl.class);
	
	private static PmsUserDao pmsUserDao;
	
	public PmsUser loadPmsUserByName(String userName) {
		logger.info("Start loadPmsUserByName");
		logger.debug("User Name: " + userName);
		PmsUser searchTemplate = new PmsUser();
		searchTemplate.setUserName(userName);
		logger.info("End loadPmsUserByName");
		return pmsUserDao.loadPmsUser(searchTemplate);
	}
	
	public PmsUser loadPmsUserByEmail(String email) {
		logger.info("Start loadPmsUserByEmail");
		logger.debug("Email: " + email);
		PmsUser searchTemplate = new PmsUser();
		searchTemplate.setEmailAddr(email);
		logger.info("End loadPmsUserByEmail");
		return pmsUserDao.loadPmsUser(searchTemplate);
	}
	
	public void saveOrUpdatePmsUser(PmsUser pmsUser) {
		logger.info("Start saveOrUpdateUser");
		pmsUserDao.saveOrUpdatePmsUser(pmsUser);
		logger.info("End saveOrUpdateUser");
	}

	public List<PmsUser> listPmsUser(PmsUser searchTemplate) {
		return pmsUserDao.listPmsUser(searchTemplate);
	}

	public List<PmsUser> listPmsUser(String searchField, String searchString, String searchOper, String sidx, String sord, Integer page, Integer rows) {
		return pmsUserDao.listPmsUser(searchField, searchString, searchOper, sidx, sord, page, rows);
	}
	
	public Integer countListPmsUser(String searchField, String searchString, String searchOper) {
		return pmsUserDao.countListPmsUser(searchField, searchString, searchOper);
	}

	/**
	 * @param pmsUserDao the pmsUserDao to set
	 */
	public void setPmsUserDao(PmsUserDao pmsUserDao) {
		logger.info("Start setPmsUserDao");
		logger.debug("PMS User Dao: " + pmsUserDao);
		this.pmsUserDao = pmsUserDao;
		logger.info("End setPmsUserDao");
	}

}
